package com.example.demo.lucene;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ResultSet implements Serializable {
    public static int SUCCESS_OK=200;

    public static int ERROR_NOT_FOUND=404;
    public static int ERROR_SYSTEM=500;
    public static int ERROR_SERVER=504;
    public static int ERROR_MSG=401;//参数异常

    private String msg;//提示
    private int status=SUCCESS_OK;//返回状态
    private int size;
    private int total;
    private int start=0;
    private int page;
    private List<Map<String,Object>> list;

    public ResultSet(){

    }
    public ResultSet(int status) {
        this.status = status;
    }

    public ResultSet(String msg, int status) {
        this.msg = msg;
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public List<Map<String, Object>> getList() {
        return list;
    }

    public void setList(List<Map<String, Object>> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        String str= "ResultSet{" +
                "msg='" + msg + '\'' +
                ", status=" + status +
                ", size=" + size +
                ", total=" + total +
                ", start=" + start +
                ", page=" + page +"\n";
        if (list!=null){
            for (Map<String, Object> map : list) {
                String maps="";
                Set<Map.Entry<String, Object>> entries = map.entrySet();
                for (Map.Entry<String, Object> entry : entries) {
                    maps+=entry.getKey()+":"+entry.getValue();
                }
                str+=maps;
            }
        }
          str+= '}';
        return str;
    }
}
